import 'package:flutter_test/flutter_test.dart';
import 'package:lmmi/common/entity/share.dart';

void main() {
  group('ShareEntity Video Tests', () {
    test('ShareEntity should have video field', () {
      final share = ShareEntity(
        id: 'test1',
        description: 'Test description',
        image: 'test_image.png',
        emotion: 'happy',
        date: '2025-08-01 12:00:00',
        commentIds: [],
        browses: 0,
        video: 'test_video.mp4',
      );

      expect(share.video, 'test_video.mp4');
      expect(share.hasVideo, true);
      expect(share.hasImage, true);
    });

    test('ShareEntity should handle empty video', () {
      final share = ShareEntity(
        id: 'test2',
        description: 'Test description',
        image: 'test_image.png',
        emotion: 'happy',
        date: '2025-08-01 12:00:00',
        commentIds: [],
        browses: 0,
        video: '',
      );

      expect(share.video, '');
      expect(share.hasVideo, false);
      expect(share.hasImage, true);
    });

    test('ShareEntity should handle no video parameter', () {
      final share = ShareEntity(
        id: 'test3',
        description: 'Test description',
        image: 'test_image.png',
        emotion: 'happy',
        date: '2025-08-01 12:00:00',
        commentIds: [],
        browses: 0,
      );

      expect(share.video, '');
      expect(share.hasVideo, false);
      expect(share.hasImage, true);
    });

    test('ShareEntity should handle empty image and video', () {
      final share = ShareEntity(
        id: 'test4',
        description: 'Test description',
        image: '',
        emotion: 'happy',
        date: '2025-08-01 12:00:00',
        commentIds: [],
        browses: 0,
        video: '',
      );

      expect(share.video, '');
      expect(share.image, '');
      expect(share.hasVideo, false);
      expect(share.hasImage, false);
    });

    test('ShareEntity fromJson should handle video field', () {
      final json = {
        'id': 'test5',
        'description': 'Test description',
        'image': 'test_image.png',
        'emotion': 'happy',
        'date': '2025-08-01 12:00:00',
        'commentIds': <String>[],
        'browses': 0,
        'video': 'test_video.mp4',
      };

      final share = ShareEntity.fromJson(json);

      expect(share.video, 'test_video.mp4');
      expect(share.hasVideo, true);
    });

    test('ShareEntity fromJson should handle missing video field', () {
      final json = {
        'id': 'test6',
        'description': 'Test description',
        'image': 'test_image.png',
        'emotion': 'happy',
        'date': '2025-08-01 12:00:00',
        'commentIds': <String>[],
        'browses': 0,
      };

      final share = ShareEntity.fromJson(json);

      expect(share.video, '');
      expect(share.hasVideo, false);
    });

    test('ShareEntity toJson should include video field', () {
      final share = ShareEntity(
        id: 'test7',
        description: 'Test description',
        image: 'test_image.png',
        emotion: 'happy',
        date: '2025-08-01 12:00:00',
        commentIds: [],
        browses: 0,
        video: 'test_video.mp4',
      );

      final json = share.toJson();

      expect(json['video'], 'test_video.mp4');
    });

    test('ShareEntity copyWith should handle video field', () {
      final share = ShareEntity(
        id: 'test8',
        description: 'Test description',
        image: 'test_image.png',
        emotion: 'happy',
        date: '2025-08-01 12:00:00',
        commentIds: [],
        browses: 0,
        video: 'old_video.mp4',
      );

      final updatedShare = share.copyWith(video: 'new_video.mp4');

      expect(updatedShare.video, 'new_video.mp4');
      expect(share.video, 'old_video.mp4'); // Original should remain unchanged
    });
  });
}
